<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>加入我们</title>
	<link rel="stylesheet" type="text/css" href="/user/css/reister.css" />
</head>
<body>
<img src="/user/img/re.jpeg">
<div id="register">
	<h1>REGISTER</h1>
	<form method="get" enctype="multipart/form-data">
		<input type="text" required="required" placeholder="请输入您的昵称" name="userName" id="userName"></input>
		<input type="text" required="required" placeholder="请设置您的账号" name="account" id="account"></input>
<!--		<input type="text" required="required" placeholder="请输入您的性别" name="sex" id="sex"></input>-->
		<select id="sex" name="sex">
			<option value="男">男</option>
			<option value="女">女</option>
		</select>
		<input type="text" required="required" placeholder="请输入您的年龄" name="age" id="age"></input>
		<input type="password" required="required" placeholder="密码" name="password" id="password"></input>
		<input type="password" required="required" placeholder="确认密码" name="password1" id="password1"></input>
		<button class="but btn btn-warning" type="button"><a href="javascript:void(0)" onclick="userRegister()">确认注册</a></button>
	</form>
</div>
</body>
<script src="https://www.jq22.com/jquery/jquery-3.3.1.js"></script>
<script>
	function userRegister(){
		if($("#password").val()==$("#password1").val()){
			var userName = $("#userName").val();
			var account = $("#account").val();
			var sex = $("#sex").val();
			var age = $("#age").val();
			var password = $("#password").val();
			$.ajax({
				url:"userRegister",
				type: "get",
				dataTable: "json",
				data:{
					userName:userName,
					account:account,
					sex:sex,
					age:age,
					password:password
				},
				success: function (data) {
					console.log(data);
					if(data.msg =="成功"){
						alert(data.msg);
						window.location.href = "/user/userLoginIndex";
					}else {
						alert(data.msg);
					}
				}
			})
		}else {
			alert("两次输入密码不一致")
		}

	}
</script>
</html>
